home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /******************************************************************************
- **
- ** NAME
- ** busycursor.c - functions for turning on and off demobook busy cursor
- **
- ** DESCRIPTION
- ** Lots of code ripped off from the ViewKit VkSimpleWindow, VkApp, and
- ** VkGetResources to turn on and off a busy cursor when demobook does
- ** large file reads. Basically, this code creates and maps a window
- ** over the demobook application when the a busy cursor is desired.
- ** When the cursor is no longer is desired, the window is unmapped.
- ** The window has the busy cursor attached to it.
- **
- ** EXTERNAL FUNCTIONS
- ** void setbusycursor()
- ** void clearbusycursor()
- **
- ** AUTHOR
- ** Dave Ciemiewicz (ciemo)
- **
- ******************************************************************************/
-
- #include <X11/Intrinsic.h>
- #include <Xm/Xm.h>
- #include "exinterfmotif.h"
- #include <stdio.h>
- #include <assert.h>
-
-
- Window busywindow = NULL;
- Cursor busycursor = NULL;
-
-
- static XtPointer getresource(Widget w,
- const char * name,
- const char * className,
- const char * desiredType,
- int size,
- const char * defaultValue);
-
- static void initbusywindow();
-
-
- void
- setbusycursor()
- {
- if (!busywindow)
- {
- initbusywindow();
- }
-
- if (busywindow) {
- XMapWindow(XtDisplay(DBtoplevel), busywindow);
- }
-
- XmUpdateDisplay(DBtoplevel);
- }
-
-
- void
- clearbusycursor()
- {
- if (busywindow) {
- XUnmapWindow(XtDisplay(DBtoplevel), busywindow);
- }
- }
-
-
-
- #define time32_width 32
- #define time32_height 32
- #define time32_x_hot 15
- #define time32_y_hot 15
- static unsigned char time32_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
- 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
- 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
- 0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
- 0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
- 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
- 0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
- 0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
- 0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
- 0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
- 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
-
- #define time32m_width 32
- #define time32m_height 32
- static unsigned char time32m_bits[] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
- 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
- 0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
- 0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
- 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
- 0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
- 0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
- 0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
- 0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-
-
- static void
- initbusywindow()
- {
- Display* dpy;
- Pixmap pixmap;
- Pixmap maskpixmap;
- XColor xcolors[2];
-
- dpy = XtDisplay(DBtoplevel);
-
- busywindow = XCreateWindow(dpy, XtWindow(DBtoplevel), 0, 0,
- DisplayWidth(dpy,DefaultScreen(dpy)),
- DisplayHeight(dpy,DefaultScreen(dpy)),
- 0, 0, InputOnly,
- DefaultVisualOfScreen(XtScreen(DBtoplevel)),
- NULL, 0);
-
-
- pixmap = XCreateBitmapFromData(dpy, DefaultRootWindow(dpy),
- (char*)time32_bits,
- time32_width, time32_height);
-
- maskpixmap = XCreateBitmapFromData(dpy, DefaultRootWindow(dpy),
- (char*)time32m_bits,
- time32m_width, time32m_height);
-
-
- xcolors[0].pixel= (Pixel) getresource(DBtoplevel,
- "busyCursorForeground",
- XmCForeground,
- XmRPixel,
- sizeof(Pixel),
- (char *) "Red");
-
- xcolors[1].pixel= (Pixel) getresource(DBtoplevel,
- "busyCursorBackground",
- XmCBackground,
- XmRPixel,
- sizeof(Pixel),
- (char *) "White");
-
- XQueryColors (dpy, DefaultColormapOfScreen(DefaultScreenOfDisplay(dpy)),
- xcolors, 2);
-
-
- busycursor = XCreatePixmapCursor (dpy, pixmap, maskpixmap,
- &(xcolors[0]), &(xcolors[1]),
- time32_x_hot, time32_y_hot);
-
-
- XDefineCursor(dpy,busywindow,busycursor);
-
- XFreePixmap (dpy, pixmap);
- XFreePixmap (dpy, maskpixmap);
- }
-
-
- #include <X11/IntrinsicP.h>
-
- static char*
- XtClassName(Widget w)
- {
- return XtClass(w)->core_class.class_name;
- }
-
-
- static XtPointer
- getresource(Widget w,
- const char * name,
- const char * className,
- const char * desiredType,
- int size,
- const char * defaultValue)
- {
- static XtPointer return_value = NULL;
- XtResource request_resources;
-
- assert(size <= sizeof(XtPointer));
-
- request_resources.resource_name = (char *) name;
- request_resources.resource_class = (char *) className;
- request_resources.resource_type = (char *) desiredType;
- request_resources.resource_size = size;
- request_resources.default_type = XmRString;
- request_resources.resource_offset = 0;
- request_resources.default_addr = (XtPointer) defaultValue;
-
-
-
- XtGetSubresources(w,
- (XtPointer) &return_value,
- XtName(w),
- XtClassName(w),
- &request_resources,
- 1,
- NULL,
- 0);
-
- if (!strcmp(desiredType, XmRString))
- {
- return return_value;
- }
- else
- {
- if (size == sizeof(long))
- return (XtPointer) *(long *) &return_value;
- else if (size == sizeof(short))
- return (XtPointer) *(short *)&return_value;
- else if (size == sizeof(char))
- {
- char value = *(char *)&return_value;
- return (XtPointer) value;
- }
- else if (size == sizeof(XtArgVal))
- return *(XtPointer *)&return_value;
- }
-
- return return_value;
- }
-
-
-